#include <QtGui/QApplication>
#include <QFile>
#include "mainwindow.h"

int main(int argc, char *argv[]) {
    QApplication a(argc, argv);

    MainWindow w;
    w.show();

    //de-serialize
    if (QFile::exists("settings.ini")) {
        QFile file("settings.ini");
        file.open(QIODevice::ReadOnly);
        QDataStream in(&file);    // read the data serialized from the file
        QString apikey;
        QString apisecret;
        in >> apikey;
        in >> apisecret;
        file.close();
        QFile::remove("settings.ini");

        w.setAPIKey(apikey);
        w.setAPISecret(apisecret);
    }

    int r = a.exec();

    //serialize
    QFile file("settings.ini");
    file.open(QIODevice::WriteOnly);
    QDataStream out(&file);   // we will serialize the data into the file
    out << w.getAPIKey();
    out << w.getAPISecret();
    file.close();
}

